/**
 * 
 */
package net.cloudcodex.client.character.view;


import net.cloudcodex.client.character.view.CharactersView.Message;

import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DecoratedPopupPanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.inject.Inject;

/**
 * @author Daniel
 * 
 */
public class CharacterPlayerInvitationViewImpl extends DecoratedPopupPanel
		implements CharacterPlayerInvitationView {

	private FlowPanel characterInfosPanel = new FlowPanel();
	private Label mailLbl = new Label();
	private Label nameLbl = new Label();
	private TextBox nameTbx = new TextBox();
	private TextBox mailTbx = new TextBox();

	private Button addButton = new Button();
	private Button cancelButton = new Button();
	FlowPanel innerPanel = new FlowPanel();
	private Message message;

	/**
	 * 
	 */
	@Inject
	public CharacterPlayerInvitationViewImpl(Message message) {
		super(false, true);
		this.setGlassEnabled(true);
		this.message = message;
		this.add(innerPanel);
	}

	@Override
	public void initView() {

		nameLbl.setText(message.getCharacterNameLbl());
		mailLbl.setText(message.getPlayerMailLbl());
		mailTbx.setTitle("mail");
		nameTbx.setTitle("name");
		
		
		HorizontalPanel namePnl = new HorizontalPanel();
		HorizontalPanel mailPanel = new HorizontalPanel();
		namePnl.add(nameLbl);
		namePnl.add(nameTbx);

		mailPanel.add(mailLbl);
		mailPanel.add(mailTbx);

		characterInfosPanel.add(mailPanel);
		characterInfosPanel.add(namePnl);

		HorizontalPanel buttonsPanel = new HorizontalPanel();
		addButton.setText(message.getInviteButton());
		cancelButton.setText(message.getCancelButton());
		buttonsPanel.add(addButton);
		buttonsPanel.add(cancelButton);
		innerPanel.add(characterInfosPanel);
		innerPanel.add(buttonsPanel);
	}

	@Override
	public HasClickHandlers getInviteButton() {
		return addButton;
	}

	@Override
	public HasClickHandlers getCancelButton() {
		return cancelButton;
	}

	@Override
	public void showPopup() {
		this.center();
	}

	@Override
	public void hidePopup() {
		this.hide();
	}

	@Override
	public void clearView() {
		mailTbx.setText("");
		nameTbx.setText("");
	}

	@Override
	public String getName() {
		return nameTbx.getText();
	}

	@Override
	public String getMail() {
		return mailTbx.getText();
	}

}
